import {LayerFeatureType} from '@/staticDict';

export function generateDefaultStyle (featureType, styleConfig) {
  let style = {}
  if (featureType === '点') {
    style = {
      iconClass: styleConfig.pointConfig.pointStyle,
      iconSize: [42, 42],
      opacity: 1,
      showLabel: styleConfig.pointConfig.showLabel,
      labelConfig: styleConfig.pointConfig.labelConfig,
      color: styleConfig.pointConfig.pointColor,
      fillColor: styleConfig.pointConfig.pointColor
    }
  } else if (featureType === '线') {
    style = {
      stroke: true,
      weight: styleConfig.polylineConfig.polylineWidth,
      color: styleConfig.polylineConfig.polylineColor,
      opacity: styleConfig.polylineConfig.polylineOpacity / 100,
      showLabel: styleConfig.polylineConfig.showLabel,
      labelConfig: styleConfig.polylineConfig.labelConfig
    }
    if (styleConfig.polylineConfig.ploylineStyle === 'dashedline') {
      style.dashArray = '5, 5'
    }
  } else if (featureType === '面') {
    style = {
      stroke: styleConfig.polygonConfig.showOutline,
      weight: styleConfig.polygonConfig.outlineWidth,
      color: styleConfig.polygonConfig.polygonColor,
      opacity: styleConfig.polygonConfig.outlineOpacity / 100,
      fill: styleConfig.polygonConfig.polygonOpacity > 0,
      fillColor: styleConfig.polygonConfig.polygonColor,
      fillOpacity: styleConfig.polygonConfig.polygonOpacity / 100,
      showLabel: styleConfig.polygonConfig.showLabel,
      labelConfig: styleConfig.polygonConfig.labelConfig
    }
    if (styleConfig.polygonConfig.outlineStyle === 'dashedline') {
      style.dashArray = '5, 5'
    }
  }
  return style
}
